<?php

class detail extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->helper('url');
        $this->load->model('detail_model');
    }

    public function index()
    {
//$data['title']="Thương mại điện tử";
//$data['path']= "empty";
        $data['title'] = "Trang chủ";
        $this->load->model("index_model");
        $data['path'] = "";
        $data['list_cate_parent'] = $this->index_model->list_cate_parent();
        $data['list_cate_child'] = $this->index_model->list_cate_child();
        $data['list_cate_child1'] = $this->index_model->list_cate_child();

        $this->load->view("detail", $data);
    }
    public function showproduct(){
        $id = $this->uri->segment(4);
        $data['path'] = "list_comment";
        $data['title'] = "Detail";
        $data['info'] = $this->detail_model->getProduct($id);
        $data['comment'] = $this->detail_model->list_comment($id);
        $this->load->view("detail", $data);
    }
    public function comment(){
        //$data['path'] = "list_comment";
        $name = $_POST['name'];
        $email = $_POST['email'];
        $title = $_POST['title'];
        $product_id = $_POST['product_id'];
        $description = $_POST['description'];
        $date = date("Y-m-d H:i:s");
        $data['path'] = "list_comment";
        //echo $date; die();
        $dataarray = array(
            'product_id' => $product_id,
            'comment_title' => $title,
            'comment_description' => $description,
            'comment_user_name' => $name,
            'comment_user_email' => $email,
            'comment_date' => $date
        );
        //echo "<pre>";
        //print_r($dataarray);
        $this->detail_model->addComment($dataarray);
        //redirect(base_url() . "detail",$data);

    }

}